import { request } from '@/utils/request';

/**
 * 添加
 * @param data
 * @returns
 */
export function addRole(data: API.RoleItem) {
  return request<API.BaseResult>(
    {
      url: '/role/addRole',
      method: 'post',
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * 删除
 * @param params
 * @returns
 */
export function deleteRole(params: API.RoleItem) {
  return request<API.BaseResult>(
    {
      url: '/role/deleteRole',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * 按Id查询
 * @param params
 * @returns
 */
export function selectRoleById(params: API.RoleItem) {
  return request<API.BaseResult>(
    {
      url: '/role/selectRoleById',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
}

/**
 * 查询所有
 * @returns
 */
export function selectAllRole(params: API.PageParams) {
  return request<API.SeachResult<API.RoleItem[]>>(
    {
      url: '/role/selectAllRole',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: true,
    },
  );
}

/**
 * 按条件查询
 * @param params
 * @returns
 */
export function selectRoleByExample(params: API.RoleItem) {
  return request<API.RoleItem[]>(
    {
      url: '/role/selectRoleByExample',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: true,
    },
  );
}

/**
 * 更新
 * @param data
 * @returns
 */
export function updateRole(data: API.RoleItem) {
  return request<API.BaseResult>(
    {
      url: '/role/updateRole',
      method: 'post',
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
}
